<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title">产品信息</h3>
    </div>
    <div class="well">
        <form class="form-inline" role="form">
            <div class="form-group">
                <label class="control-label" for="name">名称</label>
                <input type="text" class="form-control" id="name" name="name" value="<?php echo $name?>"
                       placeholder="请输入名称">
            </div>
            <div class="form-group">
                <label class="control-label" for="name">产品分类</label>
                <select id="assort" name="assort">
                    <option value="">全部</option>
                    <?php if(isset($assortList)):?>
                    <?php foreach($assortList as $key=>$alist):?>
                        <option value="<?php echo $alist['id'] ?>" <?php if($alist['id']==$assort):?> selected="selected" <?php endif;?>><?php echo $alist['caption'] ?></option>
                    <?php endforeach;?>
                    <?php endif;?>
                </select>
            </div>
            <button type="submit" class="btn btn-info"> 查询</button>
        </form>
        <div class="pagination">
            <?php if(!empty($userlimit['add'])&&$userlimit['add']=="1"):?>
            <button type="button" class="btn btn-primary" id="add_item">
                添加
            </button>
            <?php endif;?>
            <?php if(!empty($userlimit['remove'])&&$userlimit['remove']=="1"):?>
            <button type="button" class="btn btn-primary" id="remove_items">
                删除
            </button>
            <?php endif;?>
            <?php if(!empty($userlimit['add'])&&$userlimit['add']=="1"):?>
            <button type="button" class="btn btn-primary" id="upload_products">
                上传产品
            </button>
            <?php endif;?>
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-condensed table-striped">
            <thead>
            <tr>
                <th><input type="checkbox" class="rows_check" /> </th>
                <th>编号</th>
                <th>名称</th>
                <th>分类</th>
                <th>图片</th>
                <th>数量</th>
                <th>销量</th>
                <th>库存</th>
                <th>spu</th>
                <th>真实价格</th>
                <th>原价</th>
                <th>是否上架</th>
                <th>创建时间</th>
                <th>创建人</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if(isset($productList['rows'])):?>
                <?php foreach($productList['rows'] as $key=>$list):?>
                    <tr>
                        <td><input type="checkbox" class="row_check" data-id="<?php echo $list['id'] ?>" /></td>
                        <td><?php echo $key+1 ?></td>
                        <td style="width:50px"><?php echo $list['caption'] ?></td>
                        <td><?php echo $list['pname'] ?></td>
                        <td><img src="/<?php echo $list['image'] ?>" width="100" height="100" /></td>
                        <td><?php echo $list['quantity'] ?></td>
                        <td><?php echo $list['sold'] ?></td>
                        <td><?php echo $list['stock'] ?></td>
                        <td><?php echo $list['spu'] ?></td>
                        <td><?php echo $list['price'] ?></td>
                        <td><?php echo $list['sprice'] ?></td>
                        <td><?php echo $list['is_sale']=="1"?"是":"否" ?></td>
                        <td><?php echo $list['createdon'] ?></td>
                        <td><?php echo $list['createdby'] ?></td>
                        <td>
                            <?php if(!empty($userlimit['edit'])&&$userlimit['edit']=="1"):?>
                            <button type="button" class="btn btn-primary update_item"  data-id="<?php echo $list['id'] ?>">
                                修改
                            </button>
                            <?php endif;?>
                            <?php if(!empty($userlimit['remove'])&&$userlimit['remove']=="1"):?>
                            <button type="button" class="btn btn-primary remove_item"  data-id="<?php echo $list['id'] ?>">
                                删除
                            </button>
                            <?php endif;?>
                            <?php if(!empty($userlimit['edit'])&&$userlimit['edit']=="1"):?>
                            <button type="button" class="btn btn-primary upload_image"  data-id="<?php echo $list['id'] ?>">
                                上传图片
                            </button>
                            <?php endif;?>
                            <?php if(!empty($userlimit['edit'])&&$userlimit['edit']=="1"):?>
                            <a class="btn btn-primary" href="/product/products?product=<?php echo $list['id'] ?>">
                                属性设置
                            </a>
                            <?php endif;?>
                            <?php if(!empty($userlimit['edit'])&&$userlimit['edit']=="1"):?>
                            <a class="btn btn-primary make_img" data-img="<?php echo $list['image'] ?>"  data-spu="<?php echo $list['spu'] ?>">
                                生成图
                            </a>
                            <?php endif;?>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php endif;?>
            </tbody>
        </table>
        <?php if($pages>1):?>
            <div class="well well-sm" style="text-align: center"><?php echo HTML::getPageHtml($page,$pages,"/product/info?name=".$name.' &assort='.$assort)?></div>
        <?php endif;?>
    </div>
</div>
<div class="modal fade" id="list_modal" tabindex="-1" role="dialog" model="productInfo"
     aria-labelledby="myModalLabel" aria-hidden="true" style="top:10px;width:800px">
    <div class="modal-dialog" style="width:760px;top:0px;margin-top:0px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    产品分类信息
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" id="list_form" name="list_form">
                    <div class="form-group">
                        <input type="hidden" class="form-control" id="model_id" name="model_id" />
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">产品分类</label>
                        <div class="col-sm-10">
                            <select id="model_pid" class="form-control" name="model_pid">
                                <?php if(isset($assortList)):?>
                                    <?php foreach($assortList as $key=>$alist):?>
                                        <option value="<?php echo $alist['id'] ?>" <?php if($alist['id']==$assort):?> selected="selected" <?php endif;?>><?php echo $alist['caption'] ?></option>
                                    <?php endforeach;?>
                                <?php endif;?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="caption" name="caption"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">数量</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="quantity" name="quantity"
                                   placeholder="请输入数量">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">库存</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="stock" name="stock"
                                placeholder="请输入库存">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">价格</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="price" name="price"
                                   placeholder="请输入价格">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">原价</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="sprice" name="sprice"
                                   placeholder="请输入原价">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">是否上架</label>
                        <div class="col-sm-10">
                            <select id="is_sale" class="form-control" name="is_sale">
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="remark" class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" id="description_content"></textarea>
                        </div>
                        <input id="description" type="hidden" name="description">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
                <button type="button" id="saveForm" class="btn btn-primary">
                    保存
                </button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_modal" tabindex="-1" role="dialog" model="productInfo"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    上传图片
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" id="image_form" name="image_form">
                    <div class="form-group">
                        <input type="hidden" class="form-control" id="upload_id" name="upload_id" />
                        <input type="hidden" class="form-control" id="upload_spu" name="upload_spu" />
                        <input type="hidden" class="form-control" id="filename" name="name" value="image" />
                        <input type="hidden" class="form-control"  name="model" value="product" />
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">图片地址</label>
                        <div class="col-sm-10">
                            <input type="file" id="image" name="image" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
                <button type="button" id="saveImage" class="btn btn-primary">
                    上传
                </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="upload_product" tabindex="-1" role="dialog" model="productInfo"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    上传文件
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" id="upload_excel_form" name="upload_excel_form">
                    <div class="form-group">
                        <input type="hidden" class="form-control" id="product" name="product" value="product" />
                        <input type="hidden" class="form-control" id="upload_product_id" name="upload_product_id" value="" />
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">图片地址</label>
                        <div class="col-sm-10">
                            <input type="file" id="product" name="product" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
                <button type="button" id="upload_product_info" class="btn btn-primary">
                    上传
                </button>
            </div>
        </div>
    </div>
</div>
